import java.sql.DriverManager
import java.sql.ResultSet

def fileReader = new FileReader("/Users/lijinsheng/workspace/coderwk/yonyou/ufgov/platform/crux-noSensitiveTestCase/src/test/resources/db.properties")
def prop = new Properties();
prop.load(fileReader)
def url = prop.get("db.url");
def user = prop.get("db.username")
def password = prop.get("db.password");
Class.forName("oracle.jdbc.driver.OracleDriver")
def conn = DriverManager.getConnection(url, user, password)
def configs = [];
def ps = conn.prepareStatement("select id, app_function,config from template_function_config")
ResultSet rs = ps.executeQuery()
def sql = new StringBuilder();
while (rs.next()) {
    def appFunction = rs.getLong("APP_FUNCTION");
    def config = rs.getString("CONFIG");
    sql.append("update template_function_config set config='${config}' where app_function=${appFunction};\n")
}
rs.close()
def file = new File("config.sql");
if(!file.exists()){
    file.createNewFile()
}
file.write(sql.toString(),"GBK")
